/** 界面操作类型 */
export enum OperaType {
    /** 拖动并绘制工作流 */
    Drag,
    /** 链接工作量节点 */
    Linked,
    /** 查看工作流程 */
    View,
}

/** 流程节点连线类型 */
export enum LineType {
    /** 贝塞尔曲线 */
    Bezier,
    /** 折线 */
    Poly,
    /** 直线 */
    Line,
}

/** 流程节点类型 */
export enum NodeType {
    /** 开始节点 */
    StartNode,
    /** 任务节点 */
    TaskNode,
    /** 分支节点 */
    BranchNode,
    /** 合并节点 */
    MegerNode,
    /** 条件节点 */
    ConditionNode,
    /** 同步节点 */
    SyncNode,
    /** 完成节点 */
    CompleteNode,
    /** 结束节点 */
    EndNode,
    /** 异常节点 */
    ErrorNode,
}

export interface IWorkflowNode {
    type: number; // 类型
    icon: string; // 图标
    name: string; // 提示文本
}

export interface ICreateNodeData extends IWorkflowNode {
    x: number;
    y: number;
    range?: any;
    doIt?: boolean;
}

export interface ICreateNodeParam {
    createNodeParam?: ICreateNodeData;
    doCreateNodeParam?: ICreateNodeData;
    doCreateTouchNodeParam?: ICreateNodeData;
}


export const NodeArray: Array<IWorkflowNode> = [
    { type: NodeType.StartNode, icon: 'icon-start', name: '开始节点' },
    { type: NodeType.TaskNode, icon: 'icon-task', name: '任务节点' },
    { type: NodeType.BranchNode, icon: 'icon-branch', name: '分支节点' },
    { type: NodeType.MegerNode, icon: 'icon-meger', name: '合并节点' },
    { type: NodeType.ConditionNode, icon: 'icon-condition', name: '条件节点' },
    { type: NodeType.SyncNode, icon: 'icon-sync', name: '会签节点' },
    { type: NodeType.CompleteNode, icon: 'icon-complete', name: '完成节点' },
    { type: NodeType.EndNode, icon: 'icon-end', name: '结束节点' },
    { type: NodeType.ErrorNode, icon: 'icon-error', name: '错误节点' },
];

interface IPoint {
    x: number;
    y: number;
}

interface IRange extends IPoint {
    width: number;
    height: number;
    r?: number;
}
export class Range implements IRange {
    x: number;
    y: number;
    width: number;
    height: number;
    r?: number;
}

export class Point implements IPoint {
    x: number;
    y: number;

    constructor(x: number = 0, y: number = 0) {
        this.x = x;
        this.y = y;
    }

    public add?(point: IPoint = { x: 0, y: 0 }): Point {
        this.x = this.x + point.x;
        this.y = this.y + point.y;
        return this;
    }
}
